package com.george.es.exception;

import com.george.es.result.Result;
import com.george.es.result.StatusCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * <p>
 *  统一异常处理类
 * </p>
 *
 * @author GeorgeChan 2019/6/13 13:39
 * @version 1.0
 * @since jdk1.8
 */
@RestControllerAdvice
public class BaseExceptionHandler {
    /**
     * 所有异常走这里
     * @param e 异常
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    public Result error(Exception e){
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR, e.getMessage());
    }
}
